package com.alinesno.cloud.gateway.core.dispather.mina.codec;

import org.apache.mina.core.session.IoSession;
import org.apache.mina.filter.codec.ProtocolCodecFactory;
import org.apache.mina.filter.codec.ProtocolDecoder;
import org.apache.mina.filter.codec.ProtocolEncoder;

import com.alinesno.cloud.gateway.core.dispather.mina.bean.BusinessServerBean;

/**
 * 自定义解码器
 * @author WeiXiaoJin
 * @since 2020年1月31日 下午19:45:08
 */
public class MessageCodeFactory implements ProtocolCodecFactory {

	private BusinessServerBean server ; 
	
	public MessageCodeFactory(BusinessServerBean server) {
		this.server = server ; 
	}

	@Override
	public ProtocolEncoder getEncoder(IoSession session) throws Exception {
		return new RequestMessageEncoder(server) ;
	}

	@Override
	public ProtocolDecoder getDecoder(IoSession session) throws Exception {
		return new ResponseMessageDecoder(server) ; 
	}

}
